<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>16-构造函数</title>
	</head>
	<body>
		<script type="text/javascript">
			//李宝利
			var lbl = {
				uid:1,
				username:'libaoli',
				age:20,
				amount:function(){
					console.log('我没钱了!');
				}
			};
			//张端阳
			var zdy = {
				uid:2,
				username:'zhangduanyang',
				age:19,
				amount:function(){
					console.log('我的钱被libaoli造完了!');
				}
			}
			var wrx = {
				uid:3,
				username:'wangruixiang',
				age:19,
				amount:function(){
					console.log('我压根就没钱!');
				}
			}
			
			//为解决以上重复定义，所以学习构造函数
			function student(uid,username,age){
				//this表示当前对象
				this.uid = uid;
				this.username = username;
				this.age = age;
				this.amount = function(){
					console.log('都是因为钱...');
				}
			}
			
			//获取关于一个学生的对象
			var obj = new student(1,'libaoli',20);
			console.log(obj.uid+'='+obj.username+'='+obj.age);
					
					
					
			
		</script>
		
		
		
	</body>
</html>
